<?php


namespace plugin\exportcenter\app\logic;


use Exception;
use core\utils\OssUtil;
use core\utils\RandomUtil;

abstract class Export
{
    public $action = "";

    abstract function export($id, $data);

    public function uploadOss($old)
    {
        $uuid = RandomUtil::UUID();
        $date = date("Ymd");
        $path = "/upload/export/{$date}/{$uuid}" . "." . pathinfo($old, PATHINFO_EXTENSION);
        try {
            $ossUrl = OssUtil::upload($path, file_get_contents($old));
            @unlink($old);
            return $ossUrl;
        } catch (Exception $exception) {
            throw new Exception("OSS上传失败:" . $exception->getMessage());
        }
    }
}